package com.chen.forum.controller;

import com.chen.forum.DTO.PageDTO;
import com.chen.forum.Service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class ManageController {
    @Autowired
    private QuestionService questionService;

    @GetMapping("/manage")
    public String manage(Model model,
                         @RequestParam(name="page",defaultValue ="1" ) Integer page,
                         @RequestParam(name="size",defaultValue = "5") Integer size){
        PageDTO pageDTO=questionService.listAll(page,size);
        model.addAttribute("pagination",pageDTO);
        return "manage";
    }
}
